package com.coding.config;

import com.coding.handler.LiveWebSocketHandler;
import com.coding.intercepor.WebSocketInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.*;

/**
 * @author Cynicism
 * @version 1.0
 * @project DyApp
 * @description
 * @date 2024/7/9 10:03:47
 */
@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
//        registry.addHandler(new ChatWebSocketHandler(), "/chat/{userId}")
//                .addInterceptors(new WebSocketInterceptor())
//                .setAllowedOrigins("*");
        registry.addHandler(new LiveWebSocketHandler(), "/likews/{userId}/{roomId}")
                .addInterceptors(new WebSocketInterceptor())
                .setAllowedOrigins("*");
    }
}
